package com.nineclock.doc.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.doc.dto.DocFileDto;
import com.nineclock.doc.dto.DocumentDto;
import com.nineclock.doc.service.DocFolderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：zhouc
 * @date ：Created in 2021/6/28
 * @description ：
 * @version: 1.0
 */
@RestController
public class DocumentController {
    
    @Autowired
    DocFolderService docFolderService;
    
    @GetMapping("/listFolderAndFile")
    public Result<DocumentDto> folderFileList(@RequestParam("parentFoldId") Long parentFoldId, @RequestParam("keyword") String keyword) {
        DocumentDto documentDto = docFolderService.folderFileList(parentFoldId, keyword);
        return Result.success(documentDto);
    }
    
    @GetMapping("/getFileByFileId")
    public Result<DocFileDto> getFileByFileId(@RequestParam("id") Long id) {
        DocFileDto docFileDto = docFolderService.getFileByFileId(id);
        return Result.success(docFileDto);
    }
}
